/** 
 * Project Name:eleme-website 
 * File Name:Shopmenushow.java 
 * Package Name:com.eleme.service 
 * Date:2018年1月8日下午4:02:51 
 * Copyright (c) 2018, fakedesigner@163.com All Rights Reserved. 
 * 
*/  
  
package com.eleme.service;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.eleme.dbutil.Dbutil;
import com.eleme.entity.V_Shop_Main;

/** 
 * ClassName:Shopmenushow <br/> 
 * Function: TODO ADD FUNCTION. <br/> 
 * Reason:   TODO ADD REASON. <br/> 
 * Date:     2018年1月8日 下午4:02:51 <br/> 
 * @author   Vane 
 * @version   
 * @since    JDK 1.8 
 * @see       
 */
public class Shopmenushow {
	private List<V_Shop_Main> change(String sql,Object[]params){
		ResultSet rs=Dbutil.query(sql, params);
		List<V_Shop_Main> shop=new ArrayList<V_Shop_Main>();
		try {
			while (rs.next()) {
				V_Shop_Main sp = new V_Shop_Main();
				sp.setId(rs.getInt("id"));
				sp.setName(rs.getString("name"));
				sp.setDtldesc(rs.getString("dtldesc"));
				sp.setDeliverfee(rs.getFloat("deliverfee"));
				sp.setAvgdlvtime(rs.getString("avgdlvtime"));
				sp.setMonthlysold(rs.getInt("monthlysold"));
				sp.setRate(rs.getFloat("rate"));
				sp.setBussiness(rs.getInt("bussiness"));
				sp.setInsurance(rs.getInt("insurance"));
				sp.setInvoice(rs.getInt("invoice"));
				sp.setLogo(rs.getString("logo"));
				shop.add(sp);
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return shop;
	}

	public List<V_Shop_Main> findById(int bussiness){
		String sql="Select s.* From Bussiness fa, Bussiness son, shop s Where fa.id = son.parentid and son.level = 1 and fa.level =0 and s.bussiness = son.id and (fa.id = ? or son.id = ?)";
		List<V_Shop_Main> shopli=change(sql, new Object[] {bussiness, bussiness});
		System.out.println(shopli);
		return shopli;
	}
	public static void main(String[] args) {
		System.out.println(new Shopmenushow().findById(2));
	}


}
